package com.yida.gwj.expend.service.impl;

import com.yida.common.core.utils.DateUtils;
import com.yida.gwj.expend.domain.GwjMaintenanceFundsBusinessOwner;
import com.yida.gwj.expend.mapper.GwjMaintenanceFundsBusinessOwnerMapper;
import com.yida.gwj.expend.service.IGwjMaintenanceFundsBusinessOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 业务业主信息Service业务层处理
 *
 * @author lgp
 * @date 2023-02-20
 */
@Service
public class GwjMaintenanceFundsBusinessOwnerServiceImpl implements IGwjMaintenanceFundsBusinessOwnerService {
    @Autowired
    private GwjMaintenanceFundsBusinessOwnerMapper gwjMaintenanceFundsBusinessOwnerMapper;

    /**
     * 查询业务业主信息
     *
     * @param businessOwnerId 业务业主信息主键
     * @return 业务业主信息
     */
    @Override
    public GwjMaintenanceFundsBusinessOwner selectGwjMaintenanceFundsBusinessOwnerByBusinessOwnerId(Long businessOwnerId) {
        return gwjMaintenanceFundsBusinessOwnerMapper.selectGwjMaintenanceFundsBusinessOwnerByBusinessOwnerId(businessOwnerId);
    }

    /**
     * 查询业务业主信息列表
     *
     * @param gwjMaintenanceFundsBusinessOwner 业务业主信息
     * @return 业务业主信息
     */
    @Override
    public List<GwjMaintenanceFundsBusinessOwner> selectGwjMaintenanceFundsBusinessOwnerList(GwjMaintenanceFundsBusinessOwner gwjMaintenanceFundsBusinessOwner) {
        return gwjMaintenanceFundsBusinessOwnerMapper.selectGwjMaintenanceFundsBusinessOwnerList(gwjMaintenanceFundsBusinessOwner);
    }

    /**
     * 新增业务业主信息
     *
     * @param gwjMaintenanceFundsBusinessOwner 业务业主信息
     * @return 结果
     */
    @CachePut(value = "gwj:maintenance_funds_business_owner", key = "#gwjMaintenanceFundsBusinessOwner.businessOwnerId", unless = "#result == 0")
    @Override
    public int insertGwjMaintenanceFundsBusinessOwner(GwjMaintenanceFundsBusinessOwner gwjMaintenanceFundsBusinessOwner) {
        gwjMaintenanceFundsBusinessOwner.setCreateTime(DateUtils.getNowDate());
        return gwjMaintenanceFundsBusinessOwnerMapper.insertGwjMaintenanceFundsBusinessOwner(gwjMaintenanceFundsBusinessOwner);
    }

    /**
     * 修改业务业主信息
     *
     * @param gwjMaintenanceFundsBusinessOwner 业务业主信息
     * @return 结果
     */
    @Override
    public int updateGwjMaintenanceFundsBusinessOwner(GwjMaintenanceFundsBusinessOwner gwjMaintenanceFundsBusinessOwner) {
        gwjMaintenanceFundsBusinessOwner.setUpdateTime(DateUtils.getNowDate());
        return gwjMaintenanceFundsBusinessOwnerMapper.updateGwjMaintenanceFundsBusinessOwner(gwjMaintenanceFundsBusinessOwner);
    }

    /**
     * 删除业务业主信息信息
     *
     * @param businessOwnerId 业务业主信息主键
     * @return 结果
     */
    @Override
    public int deleteGwjMaintenanceFundsBusinessOwnerByBusinessOwnerId(Long businessOwnerId) {
        return gwjMaintenanceFundsBusinessOwnerMapper.deleteGwjMaintenanceFundsBusinessOwnerByBusinessOwnerId(businessOwnerId);
    }

    @Override
    public int deleteGwjMaintenanceFundsBusinessOwnerByBusinessId(Long businessId) {
        return gwjMaintenanceFundsBusinessOwnerMapper.deleteGwjMaintenanceFundsBusinessOwnerByBusinessId(businessId);
    }

    @Override
    public GwjMaintenanceFundsBusinessOwner selectGwjMaintenanceFundsBusinessOwnerByBusinessId(Long businessId) {
        return gwjMaintenanceFundsBusinessOwnerMapper.selectGwjMaintenanceFundsBusinessOwnerByBusinessId(businessId);
    }

    @Override
    public int insertBatchGwjMaintenanceFundsBusinessOwner(List<GwjMaintenanceFundsBusinessOwner> gwjMaintenanceFundsBusinessOwner) {
        return gwjMaintenanceFundsBusinessOwnerMapper.insertBatchGwjMaintenanceFundsBusinessOwner(gwjMaintenanceFundsBusinessOwner);
    }
}
